import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import path, { resolve } from 'path'
import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers';
export default defineConfig({
  server: {
    port: 5174,
    host: '0.0.0.0', // 配置项目可以局域网访问
    cors: true,
    proxy: {
      '/api': {
        target: 'http://wuliu.com/index.php',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, 'http://192.168.1.111:5173')
      }
    }
  },
  plugins: [
    vue(),
    AutoImport({
      resolvers: [
        AntDesignVueResolver({
          importStyle: false,
        }),
      ],
      include: [
        /\.[tj]sx?$/, // .ts, .tsx, .js, .jsx
        /\.vue$/,
        /\.vue\?vue/, // .vue
        /\.md$/, // .md
      ],
      imports: ['vue', 'vue-router']
    }),
    {
      "name": 'typescript-vue-plugin'
    }
  ],
  resolve: {
    alias: {
      "@": path.resolve("./src"), // @代替src
      "#": path.resolve("./types"), // #代替types
      "public": path.resolve("./public"), // $代替src/api
    },
  }
})


